package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.demo.entity.Goods;
import com.example.demo.service.GoodsService;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import com.example.demo.mq.JmsConfig;
import com.example.demo.mq.PayProducer;

@Slf4j
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @Autowired
    private PayProducer producer;

    @RequestMapping(value = "/index1")
    public String insertGoods(Goods goods) throws Exception {
//        goodsService.insertGoods(goods);
        return "/index1";
    }

    @RequestMapping(value = "/index2")
    public String deleteGoods(String GNo) throws Exception {
//        goodsService.deleteGoods(GNo);
        return "/index2";
    }

    @RequestMapping(value = "/index3")
    public String updateGoods(Goods goods) throws Exception {
//        goodsService.updateGood(goods);
        return "/index3";
    }

    @RequestMapping(value = "/selectAll")
    // http://localhost:9090/goods/selectAll
    public List<Goods> selectAll() throws Exception {
        System.out.println("index selectAll 1");

        return goodsService.selectAll();
    }

    @RequestMapping(value = "/index")
    // http://localhost:9090/goods/index?GNo=12
    public Goods findByGNo(String GNo) throws Exception {
        System.out.println("index findByGNo 4 GNo)="+GNo);

        return goodsService.findByGNo(GNo);
    }

}